package com.jackrain.clouddata.oms.util;

import java.util.Set;

/**
 * Created by nathan on 2017/8/16.
 */
public class KeyValueUtils {

    public static String valueAppend(int size){
        StringBuffer stringBuffer = new StringBuffer();
        for (int i =0;i<size;i++){
            if (i==size-1){
                stringBuffer.append("?");
            }else {
                stringBuffer.append("?,");
            }
        }
        return stringBuffer.toString();
    }

    public static String keyAppend(Set<String> set){
        StringBuffer stringBuffer = new StringBuffer();
        for (int i =0;i<set.size();i++){
            String key = (String) set.toArray()[i];
            if (i==set.size()-1){
                stringBuffer.append(key);
            }else {
                stringBuffer.append(key+",");
            }
        }
        return stringBuffer.toString();
    }


    public static String keyUpdateAppend(Set<String> set){
        StringBuffer stringBuffer = new StringBuffer();
        for (int i =0;i<set.size();i++){
            String key = (String) set.toArray()[i];
            if (i==set.size()-1){
                stringBuffer.append(key+"=?");
            }else {
                stringBuffer.append(key+"=?,");
            }
        }
        return stringBuffer.toString();
    }
}
